import * as API from '../axios'
import * as util from "@/common/util";

export default {

  getPage: (params, page) => {
    const url = util.replacePageNumAndSize('/manage/users/{pageNum}/{pageSize}', page)
    return API.axiosGetAPI(url, params)
  },

  getDetail: (id) => {
    return API.axiosGetAPI(`/manage/users/${id}`)
  },

  // 修改状态: 冻结/解冻
  modifyState: (params) => {
    const headers = {
      'lang-key': params.state == 1 ? 'Users_Status_Dropdown_Freeze' : 'Account_unfreeze'
    }
    return API.axiosPutAPI("/manage/users/state", params, headers);
  },

  // 修改身份
  modifyIdentity: (id, type) => {
    // 类型：1-普通用户 2-白名单用户
    const headers = {'lang-key': type == 1 ? 'Users_Normal_user' : 'Whitelisted_users'}
    return API.axiosPutAPI(`/manage/users/identity/${id}?type=${type}`,'',headers)
  },

  // 退押金
  refundDeposit: (id) => {
    const headers = {
      'lang-key': 'Deposit_refunded'
    }
    return API.axiosPutAPI(`/manage/users/${id}/deposit/refund`, null, headers)
  },

}